unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,Dialog_View, StdCtrls, RzEdit, ExtCtrls;

type
  TForm1 = class(TDialogView)
    Memo_Start: TRzMemo;
    Memo_Ended: TRzMemo;
    pnl1: TPanel;
    Btnx_UPPER: TButton;
    Btnx_FIRST: TButton;
    Btnx_LOWER: TButton;
    Btnx_Paste: TButton;
    Btnx_CopyT: TButton;
    Chkb_Auto: TCheckBox;
    procedure Btnx_UPPERClick(Sender: TObject);
    procedure Btnx_LOWERClick(Sender: TObject);
    procedure Btnx_FIRSTClick(Sender: TObject);
    procedure Btnx_PasteClick(Sender: TObject);
    procedure Btnx_CopyTClick(Sender: TObject);
  private
  protected
    procedure SetInitialize;override;
    procedure SetCommParams;override;
    procedure SetGridParams;override;
    procedure SetComboItems;override;
    procedure TryFreeAndNil;override;
  public
  end;

var
  Form1: TForm1;

implementation

uses
  Clipbrd,Class_KzUtils;

{$R *.dfm}

procedure TForm1.Btnx_UPPERClick(Sender: TObject);
var
  I:Integer;
  TMPA:string;
begin
  if Chkb_Auto.Checked then
  begin
    Btnx_PasteClick(Btnx_Paste);
  end;
  
  Memo_Ended.Lines.Clear;

  for I:=0 to Memo_Start.Lines.Count-1 do
  begin
    TMPA:=Trim(Memo_Start.Lines.Strings[I]);

    TMPA:=UpperCase(TMPA);
    Memo_Ended.Lines.Add(TMPA);
  end;

  if Chkb_Auto.Checked then
  begin
    Btnx_CopyTClick(Btnx_CopyT);
  end;
end;

procedure TForm1.Btnx_LOWERClick(Sender: TObject);
var
  I:Integer;
  TMPA:string;
begin
  if Chkb_Auto.Checked then
  begin
    Btnx_PasteClick(Btnx_Paste);
  end;
  
  Memo_Ended.Lines.Clear;

  for I:=0 to Memo_Start.Lines.Count-1 do
  begin
    TMPA:=Trim(Memo_Start.Lines.Strings[I]);

    TMPA:=LowerCase(TMPA);
    Memo_Ended.Lines.Add(TMPA);
  end;     

  if Chkb_Auto.Checked then
  begin
    Btnx_CopyTClick(Btnx_CopyT);
  end;  
end;

procedure TForm1.Btnx_FIRSTClick(Sender: TObject);
var
  I,M:Integer;
  TMPA:string;
  TMPB:string;
  TMPC:string;
  List:TStringList;
begin
  if Chkb_Auto.Checked then
  begin
    Btnx_PasteClick(Btnx_Paste);
  end;
  
  Memo_Ended.Lines.Clear;

  for I:=0 to Memo_Start.Lines.Count-1 do
  begin
    TMPA:=Trim(Memo_Start.Lines.Strings[I]);
    TMPA:=LowerCase(TMPA);

    TMPC:='';
    List:=TStringList.Create;
    List.DelimitedText:=TMPA;
    for M:=0 to List.Count-1 do
    begin
      TMPB:=Trim(List.Strings[M]);
      TMPB[1]:=UpCase(TMPB[1]);

      TMPC:=TMPC +' '+TMPB;
    end;
    FreeAndNil(List);
    Memo_Ended.Lines.Add(Trim(TMPC));
  end;

  if Chkb_Auto.Checked then
  begin
    Btnx_CopyTClick(Btnx_CopyT);
  end;    
end;

procedure TForm1.Btnx_PasteClick(Sender: TObject);
begin
  if Clipboard.HasFormat(CF_TEXT) then
  begin
    Memo_Start.Lines.Clear;
    Memo_Start.Lines.Add(Clipboard.AsText);
  end;
end;

procedure TForm1.SetComboItems;               
begin
  inherited;

end;

procedure TForm1.SetCommParams;
begin
  inherited;
  Caption:='uppercase';

  if FileExists(TKzUtils.ExePath+'auto') then
  begin
    Chkb_Auto.Checked:=True;
  end;
end;

procedure TForm1.SetGridParams;
begin
  inherited;

end;

procedure TForm1.SetInitialize;
begin
  inherited;

end;

procedure TForm1.TryFreeAndNil;
begin
  inherited;

end;

procedure TForm1.Btnx_CopyTClick(Sender: TObject);
begin
  Clipboard.AsText:=Trim(Memo_Ended.Text);
end;

end.
 